class Node:
    def __init__(self, initdata):
        self.data = initdata  # 初始化节点的数据
        self.next = None  # 该节点目前没有指向任何其他节点

    def getdata(self):
        return self.data

    def getnext(self):
        return self.next

    def setdata(self, newdata):
        self.data = newdata

    def setnext(self, newnext):
        self.next = newnext


class OrderedList:
    def __init__(self):
        self.head = None  # 链表的头节点初始化为None，表示初始状态下链表为空。

    def search(self, item):
        current = self.head  # 为空
        found = False  # 找到
        stop = False  # 停止
        while current is not None and not stop and not found:
            if current.getdata() == item:
                found = True
            else:
                if current.getdata() > item:
                    stop = True
                else:
                    current = current.getnext()
        return found

    def add(self, item):
        current = self.head
        previous = None
        stop = False
        while current is not None and not stop:
            if current.getdata() > item:  # 找到插入位置
                stop = True
            else:
                previous = current
                current = current.getnext()
        temp = Node(item)
        if previous is None:  # 链表头
            temp.setnext(self.head)
            self.head = temp
        else:  # 链表中
            temp.setnext(current)
            previous.setnext(temp)
